﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace CommLib.BdPush
{
    public sealed class AlertInfo
    {
        public string title { get; set; }
        public string body { get; set; }
    }
    public sealed class Aps_Mod
    {
        public AlertInfo alert { get; set; }
        public string sound { get; set; }
        public int badge { get; set; }
        public string ContentFlag { get; set; }

        public Aps_Mod()
        {
            ContentFlag = "1";
            sound = "default";
            badge = 0;
            alert=new AlertInfo();
            
        }
    }

    //iOS通知格式
    //{
    //    "aps": {  
    //         "alert":"Message From Baidu Cloud Push-Service",
    //         "content-available":"1",
    //         "sound":"default",  //可选
    //          "badge":0,    //可选
    //    },
    //    "JsonData":"Json"
    //}
    //{
    //    "aps" : {
    //        "alert" : {
    //            "title" : "Game Request",
    //            "body" : "Bob wants to play poker",
    //            "action-loc-key" : "PLAY"
    //        },
    //        "badge" : 5
    //    },
    //    "acme1" : "bar",
    //    "acme2" : [ "bang",  "whiz" ]
    //}
    public sealed class Notice_iOS_Mod
    {
        public Aps_Mod aps { get; set; }
        public string custom_content { get; set; }

        public Notice_iOS_Mod(string title, string description)
        {
            aps = new Aps_Mod();
            aps.alert.title = title;
            aps.alert.body = description;
            custom_content = "custom_content";

        }

        public string toJson(string custom_content)
        {
            var result = JsonConvert.SerializeObject(this);
            result = result.Replace("ContentFlag", "content-available");
            if (!string.IsNullOrEmpty(custom_content))
            {
                result = result.Replace("\"custom_content\":\"custom_content\"", custom_content);
            }
            return result;
        }

        public string toJson()
        {
            var result = toJson("");
            return result;
        }
    }
}